package qreasymarket.movil;

import org.json.JSONArray;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.sax.StartElementListener;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class PrincipalAndroid extends Activity {
	TextView user_actual;
	Button btnLogout;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.principal);

		// btnLogout = (Button) findViewById(R.id.btnLogout);
		// user_actual = (TextView) findViewById(R.id.usuario_actual);

		/*
		 * Intent intencion = getIntent(); Bundle datos = intencion.getExtras();
		 * user_actual.setText(datos.getString("valor1"));
		 * 
		 * String UsuarioActual = user_actual.getText().toString();
		 * System.out.println("COMPROBADO" + "  :" + UsuarioActual);
		 */
	}

	public void scanear(View view) {

		/*
		 * Intent intencion = getIntent(); Bundle datos = intencion.getExtras();
		 * user_actual.setText(datos.getString("valor1"));
		 * 
		 * String UsuarioActual = user_actual.getText().toString();
		 * System.out.println("COMPROBADO" + "  :" + UsuarioActual);
		 * 
		 * RestClient cliente1 = new RestClient(
		 * "http://192.168.81.88:8080/QR-EasyMarket_Web/rest/capturar_idcliente"
		 * );
		 * 
		 * cliente1.AddParam("email", UsuarioActual);
		 * 
		 * try { cliente1.Execute(RequestMethod.GET); String jsontext =
		 * cliente1.getResponse(); Log.i("PrincipalActivity", jsontext);
		 * 
		 * JSONArray entries = new JSONArray(jsontext);
		 * 
		 * jsontext = jsontext.toLowerCase().trim();
		 * 
		 * // SOLUCION PERO SALE CON TODOS LOS ATRIBUTOS
		 * 
		 * int b;
		 * 
		 * for (b = 0; b < entries.length(); b++) {
		 * 
		 * JSONObject post = entries.getJSONObject(b); String idXxxx =
		 * post.getString("idCliente"); System.out.println(idXxxx);
		 * Log.i("PrincipalAndroid", idXxxx);
		 * 
		 * Intent a = new Intent(PrincipalAndroid.this,
		 * ListaCompraActivity.class); Bundle user = new Bundle();
		 * user.putString("id", idXxxx); a.putExtras(user); startActivity(a);
		 * 
		 * } // TERMINA SOLUCION
		 * 
		 * } catch (Exception e) { Log.i("PrincipalActivity", "ERROR:" +
		 * e.getMessage()); }
		 */
	}

	public void delivery(View view) {

		startActivity(new Intent(PrincipalAndroid.this, DeliveryActivity.class));
	}

	public void promociones(View view) {
		startActivity(new Intent(PrincipalAndroid.this,
				PromocionesActivity.class));
	}

	public void logout(View view) {

		finish();

	}
}
